<template>
	<!-- 添加形象视频 -->
	<view class="flex-col page">
		<view class="back-w" style="position: fixed;z-index: 9; height: 100rpx;">
			<view class="u-m-l-10" @click="Back()">
				<u-icon name="arrow-left" color="#000000" size="20"></u-icon>
			</view>
			<view class="f-w-l">
				巡检服务</view>
		</view>
		<view class="flex-col group" style="margin-top: 120rpx;">
			<view class="flex-col section_1">
				<view class="flex-row">
					<image :src="infolist.address" mode="" class="image_1"></image>
					<text class="text_1">{{this.infolist.consumerName}}（{{this.infolist.position}}）</text>
				</view>
				<text class="text_2">巡检服务订单</text>
				<text class="text_3">{{this.infolist.detailedName}}</text>
				<text class="text_4">房屋位置：{{this.infolist.provinceName}}{{this.infolist.cityName}}{{this.infolist.districtName}}</text>
				<text class="text_5">房屋面积：{{this.infolist.roomArea}}m²</text>
			</view>
			<view class="flex-col section_2">
				<view class="flex-col group_2">
					<text class="text_6">项目进度简述</text>
					<view class="flex-col items-start text-wrapper">
						<textarea name="" id="" cols="30" rows="10" placeholder="请输入项目进度简述" v-model="processDetails"
							style="font-size: 28rpx;padding-left: 20rpx;"></textarea>
					</view>
					<text class="text_8">上传视频</text>
					<view style="margin-top: 50rpx;">
						<uni-file-picker style="width: 100%;" :value="fileList" limit="1" 
							fileMediatype="video" mode="grid" ref="files" @select="select" @delete="del"
							:image-styles="imageStyles" :auto-upload="false"  @fail="fail">
							<image :src="$IMG_URL+'16557826807714447598.png'" mode="widthFix"
								style="width: 214rpx;height: 214rpx;">
							</image>
						</uni-file-picker>
					</view>

				</view>
				<view class="flex-col items-center button" @click="sure"><text class="text_9">确认</text></view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		components: {},
		props: {
			maxCount: {
				type: Number,
				default: 1
			},
			fileList: {
				type: Array
			}
		},
		data() {
			return {
				imageValue: [],
				imageStyles: {
					width: 110,
					height: 110,

				},
				videos:'',
				processDetails:'',
				ordersId:'',
				infolist:[]
			};
		},
		onLoad(option) {
			this.ordersId = option.ordersId;
			
		},
		created() {
			this.getinfo()
			uni.startPullDownRefresh();
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		methods: {
			Back() {
				let  pageNum = 2
				let pages = getCurrentPages(); // 当前页面
				let beforePage = pages[pages.length - pageNum]; 
				uni.navigateBack({
					success: function() {
						// console.log(beforePage)
						beforePage.$vm.$refs.video.getlist(); 
					}
			
				})
			},
			del(e) {
				this.$emit('del', e.index);
			},
			select(e) {
				this.show = true;
				if (e.tempFilePaths.length > 0) {
					e.tempFilePaths.map(item => {
						this.upload(item)
					})
				}

			},
			// 上传失败
			fail(e) {
				console.log('上传失败：', e)
			},
			upload(url) {
				console.log('上传')
				uni.uploadFile({
					url: this.$API_URL + '/app3/upload/uploadOne', 
					filePath: url,
					fileType:'video',
					name: 'file',
					success: (res) => {
						res = JSON.parse(res.data)
						if (res.code == 200) {
							console.log(res.data, 'res')
							this.videos=res.data
							uni.showToast({
								title:'上传成功',
								icon:"success"
							})
						} else {
							uni.showToast({
								title:res.msg,
								icon:"error"
							})
						}

					}
				});
			},
			sure() {
				let inspectionFrequencyId=this.infolist.inspectionFrequencyId
				this.$http('onsite.upvideos', {
					inspectionFrequencyId: inspectionFrequencyId,
					processDetails: this.processDetails,
					videos: this.videos
				}).then(res => {
					console.log(res)
					if (res.code == 200) {
						let  pageNum = 2
						let pages = getCurrentPages(); // 当前页面
						let beforePage = pages[pages.length - pageNum]; // 前一个页面
					
						uni.navigateBack({
							success: function() {
									beforePage.$vm.$refs.video.getlist(); 
						    }						
						  }
						);
					
					}else{
						uni.showToast({
							title:res.msg,
							icon:"error"
						})
						return;
					}
				})

			},
			getinfo(){
				// 获取信息
				let inspectionFrequencyId=uni.getStorageSync('inspectionFrequencyId');
				
				this.$http('common.getInfolist',{
					ordersId:this.ordersId,
					type:'5',
					inspectionFrequencyId:inspectionFrequencyId
				}).then(res=>{
					if(res.code==200){
						this.infolist = res.data
					}else{
						
					}
				})
			}
		},
	};
</script>

<style scoped lang="scss">
	.page {
		background-color: #f6f7f9;
		width: 100%;
		overflow-y: auto;
		overflow-x: hidden;
		height: 100%;
	}

	.group {
		flex: 1 1 auto;
		overflow-y: auto;
	}

	.section_1 {
		padding: 32rpx 32rpx 35rpx;
		background-color: #ffffffff;
	}

	.section_2 {
		margin-top: 20rpx;
		padding: 0 31rpx 40rpx;
		background-color: #ffffffff;
	}

	.text_2 {
		margin-top: 21rpx;
		align-self: flex-start;
		color: #333333;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
		font-weight: 600;
	}

	.text_3 {
		margin-top: 32rpx;
		align-self: flex-start;
		color: #333333;
		font-size: 26rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 30rpx;
	}

	.text_4 {
		margin-top: 27rpx;
		align-self: flex-start;
		color: #333333;
		font-size: 26rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 30rpx;
	}

	.text_5 {
		margin-top: 33rpx;
		align-self: flex-start;
		color: #333333;
		font-size: 26rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 30rpx;
	}

	.group_2 {
		padding: 29rpx 0;
	}

	.button {
		margin-top: 35rpx;
		padding: 19rpx 0 31rpx;
		background-color: #1d6aff;
		border-radius: 44rpx;
	}

	.image_1 {
		border-radius: 50%;
		width: 64rpx;
		height: 64rpx;
	}

	.text_1 {
		margin-left: 16rpx;
		margin-top: 10rpx;
		color: #333333;
		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
	}

	.text_6 {
		align-self: flex-start;
		color: #191919;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
		font-weight: 600;
	}

	.text-wrapper {
		margin-top: 33rpx;
		padding: 23rpx 0;
		border-radius: 16rpx;
		background-image: url($IMG_URL+'16557870928220192831.png');
		background-size: 100% 100%;
		background-repeat: no-repeat;
	}

	.text_8 {
		margin-top: 36rpx;
		align-self: flex-start;
		color: #191919;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
	}

	.image_2 {
		margin-top: 34rpx;
		align-self: flex-start;
		width: 214rpx;
		height: 214rpx;
	}

	.text_9 {
		color: #ffffff;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
	}

	.text_7 {
		margin-left: 25rpx;
		color: #999999;
		font-size: 28rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 33rpx;
	}
</style>
